<template>
  <div class="home">
    跨域讲解--
    <button @click="jump">跳转</button>
  </div>
</template>

<script>
// @ is an alias to /src
import axios from 'axios';
import { useRouter } from 'vue-router';
export default {
  name: 'HomeView',
  components: {

  },
  setup(props) {
    const { push } = useRouter();
    // axios.get('/api').then(res => {
    //   console.log(res);
    // })
    //  axios.get('/request').then(res => {
    //   console.log(res);
    // })

    // 路由传参的三种方式
    // 1.query 传参
    // let id = 888;
    // 2.params 传参 // 使用name作为标识，刷新数据会丢失
    // 3.使用动态路由传参
    let obj = {
      name: '李杨',
      explan: '贼拉跨'
    }
    let id = 888;
    const jump = () => {
      // push({path:'/result',query:obj})
      // push({name:'Result',params:obj})
      push(`/result/${JSON.stringify(obj)}`);
    }
    return {
      jump
    }
  }
}
</script>
